package team.seekers.hula.common.entity.enums;

import com.baomidou.mybatisplus.core.enums.IEnum;
import lombok.Getter;

import java.util.Arrays;

/**
 * @author ekin
 * @Description GOOD
 * @mood happy
 */
@Getter
public enum IslandTypeEnum implements IEnum<Integer> {
    MEMORY(0, "MEMORY", "记忆"),
    TOPIC(1, "TOPIC", "帖子"),
    CARD(2, "CARD", "文章");

    private int type;

    private String name;

    private String cnName;

    IslandTypeEnum(int type, String name, String cnName) {
        this.type = type;
        this.name = name;
        this.cnName = cnName;
    }

    @Override
    public Integer getValue() {
        return this.type;
    }

    public static IslandTypeEnum getByType(int type) {
        return Arrays.stream(values()).filter(e -> e.getType() == type).findFirst().orElse(null);
    }

    public static IslandTypeEnum getByName(String name) {
        return Arrays.stream(values()).filter(e -> e.getName().equals(name)).findFirst().orElse(null);
    }
}
